{% extends "base.html" %}

{% block title %}潜水知识 - 万岛潜水{% endblock %}

{% block content %}
<div class="container mt-5">
    <h1 class="text-center mb-5">潜水知识</h1>
    
    <div class="row">
        <div class="col-12">
            {% if posts %}
                <div class="row">
                {% for post in posts %}
                    <div class="col-md-6 mb-4">
                        <div class="card h-100">
                            {% if post.image %}
                            <img src="{{ url_for('static', filename='uploads/' + post.image) }}" class="card-img-top" alt="{{ post.title }}">
                            {% endif %}
                            <div class="card-body d-flex flex-column">
                                <h5 class="card-title">{{ post.title }}</h5>
                                <p class="card-text text-muted small">发布于: {{ post.created_at.strftime('%Y-%m-%d') }}</p>
                                <p class="card-text">{{ post.content|striptags|truncate(150) }}</p>
                                <a href="{{ url_for('main.post_detail', id=post.id) }}" class="btn btn-primary mt-auto">阅读更多</a>
                            </div>
                        </div>
                    </div>
                {% endfor %}
                </div>
            {% else %}
                <div class="alert alert-info">
                    暂无潜水知识文章，请稍后再来查看。
                </div>
            {% endif %}
        </div>
    </div>
    
    <div class="row mt-5">
        <div class="col-12">
            <div class="card bg-primary text-white">
                <div class="card-body text-center p-4">
                    <h3 class="card-title">想了解更多潜水知识？</h3>
                    <p class="card-text">加入我们的课程，由专业教练为您详细讲解！</p>
                    <a href="{{ url_for('main.courses') }}" class="btn btn-light btn-lg">查看课程</a>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %} 